package com.platform.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;

import com.platform.comm.web.results.TreeNode;
import java.util.List;


/**
 * View Object for
 * @author Coder
 */
@Getter
@Setter
public class InterfaceTypeDto extends TreeNode {

    /**
     * 接口列表
     */
    private List<InterfaceDto> interfaces;

    private String parentId;
    private Integer lock;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private ConfTypeTreeData data;


    public static InterfaceTypeDto of(ConfTypeTreeNode confTypeTreeNode) {
        InterfaceTypeDto interfaceTypeDto = new InterfaceTypeDto();
        interfaceTypeDto.setParentId(confTypeTreeNode.getParentId());
        interfaceTypeDto.setData(confTypeTreeNode.getData());
        interfaceTypeDto.setLock(confTypeTreeNode.getLock());
        interfaceTypeDto.setCode(confTypeTreeNode.getCode());
        interfaceTypeDto.setId(confTypeTreeNode.getId());
        interfaceTypeDto.setText(confTypeTreeNode.getCode());
        interfaceTypeDto.setChildren(confTypeTreeNode.getChildren());
        return interfaceTypeDto;
    }

    public static InterfaceTypeDto of(TreeNode entity) {
        InterfaceTypeDto interfaceTypeDto = new InterfaceTypeDto();
        interfaceTypeDto.setCode(entity.getCode());
        interfaceTypeDto.setId(entity.getId());
        interfaceTypeDto.setText(entity.getCode());
        interfaceTypeDto.setChildren(entity.getChildren());
        return interfaceTypeDto;
    }
}
